package com.lksoft.bz;

import java.util.HashMap;
import java.util.Locale;

import javax.swing.Action;
import javax.swing.JRadioButtonMenuItem;

import com.lksoft.bz.action.ChangeLanguageAction;

/**
 * Available languages and locales
 * 
 * @author lake
 *
 */
public class Languages {	
	HashMap<Locale, Action> languageActions = new HashMap<>();
	HashMap<Locale, JRadioButtonMenuItem> languageButtons = new HashMap<>();
	
	Locale[] supportedLanguages = {
		Locale.ENGLISH,
		Locale.JAPANESE,
		Locale.ITALIAN
	};
	
	/**
	 * Set system languages
	 */
	public Languages(Bz bz){
		for( Locale l : supportedLanguages ){
			Action action = new ChangeLanguageAction(bz, l);
			languageActions.put(l, action);
			languageButtons.put(l, new JRadioButtonMenuItem(action));
		}
	}
	
	/**
	 * Gets the change action for a specified locale
	 * @param language
	 * @return
	 */
	public Action getLanguageAction(Locale language) {
		return languageActions.get(language);
	}
	
	/**
	 * Gets the radio button for a specified locale
	 * @param language
	 * @return
	 */
	public JRadioButtonMenuItem getRadioButton(Locale language) {
		return languageButtons.get(language);
	}
}
